<?php

namespace app\common\model;

use think\Db;
use think\Model;
use linghuo\v2\Linghuo;

/**
 * 会员模型
 */
class userIdCard extends Model
{
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    public function updateEmptySystemid()
    {
    	$data = $this
    		->where('systemId','=','')
    		->whereNull('systemId','or')
    		// ->limit(1)
    		// ->fetchSql(true)
    		->select();
    	$linghuo = new Linghuo;
		foreach ($data as $value) {
			$res = $linghuo->getsystemid(Linghuo::GET_SYSTEM_ID_TYPE_3,$value->idCard);
			if ($res['code'] !==1 || empty($res['data']['result']) || empty($res['data']['result']['systemId'])) {
				continue;
			}
			$value->systemId = $res['data']['result']['systemId'];
			$value->save();
		}
    }
    public function addIdCard($option)
    {
    	$this->insertGetId($option);
    }
}
